<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>登录页面 - 光年(Light Year Admin)后台管理系统模板</title>
    <link rel="icon" href="/favicon.ico" type="image/ico">
    <meta name="keywords" content="LightYear,光年,后台模板,后台管理系统,光年HTML模板">
    <meta name="description" content="LightYear是一个基于Bootstrap v3.3.7的后台管理系统的HTML模板。">
    <meta name="author" content="yinqi">
    <link href="/admin/css/bootstrap.min.css" rel="stylesheet">
    <link href="/admin/css/materialdesignicons.min.css" rel="stylesheet">
    <link href="/admin/css/style.min.css" rel="stylesheet">
    <link href="/admin/css/login.css" rel="stylesheet">
    <link href="/admin/js/jconfirm/jquery-confirm.min.css" rel="stylesheet">
</head>

<body>
    <div class="lyear-login-box">
        <div class="lyear-login-left" style="background-image: url(/admin/images/login-bg-4.jpg)">
            <div class="lyear-overlay"></div>
            <div class="lyear-featured">
                <h4>愿你有好运气，如果没有，愿你在不幸中学会慈悲；愿你被很多人爱，如果没有，愿你在寂寞中学会宽容。<small> - 刘瑜《愿你慢慢长大》</small></h4>
            </div>
        </div>
        <div class="lyear-login-right">

            <div class="lyear-logo text-center">
                <a href="#!"><img src="/admin/images/logo-sidebar.png" alt="logo" /></a>
            </div>
            <div class="form-group">
                <label for="username">用户名</label>
                <input type="text" class="form-control" id="username" placeholder="请输入您的用户名">
            </div>

            <div class="form-group">
                <label for="password">密码</label>
                <input type="password" class="form-control" id="password" placeholder="请输入您的密码">
            </div>

            <div class="form-group">
                <label for="captcha">验证码</label>
                <div class="row">
                    <div class="col-xs-7">
                        <input type="text" name="captcha" id="captcha" class="form-control" placeholder="验证码">
                    </div>
                    <div class="col-xs-5">
                        <!-- {:captcha_img()} -->
                        <img src="{:captcha_src()}" class="pull-right" id="captcha" style="cursor: pointer;height: 38px;"
                            onclick="this.src=this.src+'?d='+Math.random();" title="点击刷新" alt="captcha">
                    </div>
                </div>
            </div>



            <div class="form-group">
                <button class="btn btn-block btn-primary" onclick="doLogin()">立即登录</button>
            </div>
            <footer class="text-center">
                <p class="m-b-0">Copyright © 2021 <a href="http://lyear.itshubao.com">Atlaxy</a>. All right reserved</p>
            </footer>

        </div>
    </div>
    <script type="text/javascript" src="/admin/js/jquery.min.js"></script>
    <script type="text/javascript" src="/admin/js/bootstrap.min.js"></script>
    <script src="/admin/js/jconfirm/jquery-confirm.min.js"></script>
    <script type="text/javascript">
        function doLogin(){
            let username = $('#username').val();
            let password = $('#password').val();
            let captcha = $('#captcha').val();
            if(!username || !password || !captcha){
                $.alert({
                    title: '错误',
                    content: '请输入登陆信息',
                    type: 'red',
                });
                return false;
            }
            $.ajax({
                url: '/admin/user/login',
                type: 'POST',
                data: {
                    username: username,
                    password: password,
                    captcha: captcha,
                },
                success: function(res){
                    if(res.code == 1){
                        window.location.href = '/admin/index';
                    }else{
                        $.alert({
                            title: '错误',
                            content: res.msg,
                            type: 'red',
                        });
                    }
                }
            });
        }
    </script>
</body>

</html>